home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / BBS / MUBBS / MUBBS etc.cpt / Module Source / Send File Module code / Send File Module.c < prev    next >
Text File  |  1991-11-19  |  3KB  |  107 lines

  1. /*
  2.  *  Send File Module.c
  3.  *
  4.  *    This program source code and it's compiled version is
  5.  *  Copyright (c) 1991 N. Hawthorn.
  6.  *  This program source code and it's compiled version IS NOT IN THE
  7.  *  PUBLIC DOMAIN ! Please read the "COPYRIGHT NOTICE / NH" file for details
  8.  *  regarding use of this program source code and it's compiled version.
  9.  *
  10.  *  This module's name is "sendfile", it's type is "MOD1", it's ID is 133
  11.  *  because we know the menu module's ID is 131. Normally a resource mover
  12.  *  would assign a new number to it, that's why we name our modules !
  13.  *
  14.  *  This is where it all starts...
  15.  *
  16.  */
  17.  
  18. #define INMAIN
  19.  
  20. #include     <SetUpA4.h>
  21. #include    "MUBBS Module.h"
  22.  
  23.  
  24. pascal void main (mode1,G1,P1)
  25.        int mode1;
  26.        struct GS *G1;
  27.        Ptr *P1; /* we ignore "P" in this module */
  28. {
  29. Handle temph;
  30. float version = 0.5; /* what version of MUBBS you are compatable with IE: .5 and above */
  31. RememberA0(); SetUpA4(); /* This sets up the A4 register to access our globals */
  32. asm { _RecoverHandle }; asm {move.l a0,temph}; HLock(temph); /* locks our module, do this ! */
  33.  
  34. G=G1; /* This MUST be the first thing you do in main only, it sets up the struct globals */
  35. mode[u]=mode1; /* set up our mode so that you can read it anywhere */
  36.  
  37. switch (mode[u]) { /* any un-handled modes return error from this module */
  38.     case 2:
  39.         sendthem();
  40.         G->moduleresult=0;
  41.         break;
  42.     case 98:
  43.         versionck(version); /* just return after this call, don't modify anything */
  44.         break;        
  45.     case 0:
  46.         strcpy (G->programmer,"N Hawthorn"); /* show the programmer's name up to 20 chars*/
  47.         G->moduleresult=0; /* this was also a init call if we need close call put 99 here */
  48.         break;
  49.     default:
  50.         G->moduleresult=1; /* return bad code */
  51.         break;
  52.     };
  53.  
  54. HUnlock(temph); /* unlocks this module, do this ! */
  55. RestoreA4(); /* call this when you are all done */
  56. }
  57.  
  58.  
  59.  
  60. sendthem() /* send a list of files in order */
  61. {
  62. FILE *stream;
  63. char tosend[21][65]; /* takes up about 1K of stack space, names not over 64 chars */
  64. char filename[65];
  65. int i,x;
  66.  
  67. if (!G->online[u]) return; /* do this check so we can log out if hang up */
  68.  
  69. /* Generate the filename */
  70. strcpy(filename,":send:");
  71. strcat(filename,G->modulename[u]);
  72. strcat(filename,".info");
  73.  
  74. loguser(G->modulename[u]); /* this tells where you are for remote sysop, or writes to log file */
  75.  
  76.  
  77. if ((stream = fopen(filename, "r")) == NULL) { /* Open the file */
  78.     send("]FILE ERROR cannot open %s ]", filename);
  79.     return;
  80.     }
  81. else    /* If no error, read from the file */
  82.     {
  83.                     
  84.     i = 0;
  85.     while (i < 20){
  86.         if (fscanf(stream,"%64[^\n]\n",tosend[i]) == EOF) break; /* end on EOF */
  87.         i++;
  88.         }
  89.     fclose(stream); /* always close the file even if empty */
  90.     }
  91.  
  92.     if (i==0) return; /* exit if file empty */
  93.  
  94.     for (x = 0; x<i; x++) /* send the files */
  95.         {
  96.         G->okcancel[u]=TRUE;
  97.         G->nocheck[u]=FALSE; /* check for controls */
  98.         G->cancel[u]=FALSE;
  99.         sendtext(tosend[x]);
  100.         if (!G->online[u]) break; /* do this check so we can log out if hang up */
  101.         }
  102. }
  103.  
  104.  
  105.  
  106.  
  107.